/*****************************************************************/
/*Date:	  November 11, 2021										 */
/*Author: UNT REP												 */
/*File:   POB.do						        				 */
/*Purpose:Analyze public opinion data on effective participation */
/*			2017 CMPS. 						 					 */
/*  	Input File: 	CMPS2016.dta							 */
/*  	Output File: 	participation.log						 */
/*****************************************************************/

*version 15
set more off

use CMPS-PB.dta

/* Models Presented in Table 1 and Table C of the Appendix */
/* prvalue estimates are used to create Figures 1, 2, and 3 */

/*Additive Models */
version 14.2: ologit protest_effect concern_crime police_contact dem ind lib mod no_ideology income income_refuse age female educ old_south zip_per_black  zip_per_latino percap_cou_violent14 zip_percap_polkillings black_resp hisp_resp friend_felon  [pw=weight], cluster(zipcode)
prvalue, x(zip_percap_polkillings=0) rest(mean) save
prvalue, x(zip_percap_polkillings=.56) rest(mean) diff
 
version 14.2: ologit voting_effect concern_crime police_contact dem ind lib mod no_ideology income income_refuse age female educ old_south zip_per_black  zip_per_latino percap_cou_violent14 zip_percap_polkillings black_resp hisp_resp friend_felon   [pw=weight], cluster(zipcode)
prvalue, x(zip_percap_polkillings=0) rest(mean) save
prvalue, x(zip_percap_polkillings=.56) rest(mean) diff

/*Interactive Models */
version 14.2: ologit protest_effect concern_crime police_contact dem ind lib mod no_ideology income income_refuse age female educ old_south zip_per_black zip_per_latino percap_cou_violent14 zip_percap_polkillings friend_felon black_resp black_polkilling hisp_resp hisp_polkilling   [pw=weight], cluster(zipcode)
prvalue, x(black_resp=0 zip_percap_polkillings=0   black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.05 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.1  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.15 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.2  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.25 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.3  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.35 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.4  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.45 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.5  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.55 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 

prvalue, x(black_resp=1 zip_percap_polkillings=0   black_polkilling=0   hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.05 black_polkilling=.05 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.1  black_polkilling=.10 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.15 black_polkilling=.15 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.2  black_polkilling=.20 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.25 black_polkilling=.25 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.3  black_polkilling=.30 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.35 black_polkilling=.35 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.4  black_polkilling=.40 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.45 black_polkilling=.45 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.5  black_polkilling=.50 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.55 black_polkilling=.55 hisp_resp=0 hisp_polkilling=0) rest(mean) 

prvalue, x(black_resp=0 zip_percap_polkillings=0   black_polkilling=0 hisp_resp=1 hisp_polkilling=0)   rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.05 black_polkilling=0 hisp_resp=1 hisp_polkilling=.05) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.1  black_polkilling=0 hisp_resp=1 hisp_polkilling=.1)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.15 black_polkilling=0 hisp_resp=1 hisp_polkilling=.15) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.2  black_polkilling=0 hisp_resp=1 hisp_polkilling=.2)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.25 black_polkilling=0 hisp_resp=1 hisp_polkilling=.25) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.3  black_polkilling=0 hisp_resp=1 hisp_polkilling=.3)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.35 black_polkilling=0 hisp_resp=1 hisp_polkilling=.35) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.4  black_polkilling=0 hisp_resp=1 hisp_polkilling=.4)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.45 black_polkilling=0 hisp_resp=1 hisp_polkilling=.45) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.5  black_polkilling=0 hisp_resp=1 hisp_polkilling=.5)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.55 black_polkilling=0 hisp_resp=1 hisp_polkilling=.55) rest(mean) 

version 14.2: ologit voting_effect concern_crime police_contact dem ind lib mod no_ideology income income_refuse age female educ old_south zip_per_black zip_per_latino percap_cou_violent14 zip_percap_polkillings black_resp black_polkilling hisp_resp hisp_polkilling friend_felon [pw=weight], cluster(zipcode)
prvalue, x(black_resp=0 zip_percap_polkillings=0   black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.05 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.1  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.15 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.2  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.25 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.3  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.35 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.4  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.45 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.5  black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.55 black_polkilling=0 hisp_resp=0 hisp_polkilling=0) rest(mean) 

prvalue, x(black_resp=1 zip_percap_polkillings=0   black_polkilling=0   hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.05 black_polkilling=.05 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.1  black_polkilling=.10 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.15 black_polkilling=.15 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.2  black_polkilling=.20 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.25 black_polkilling=.25 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.3  black_polkilling=.30 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.35 black_polkilling=.35 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.4  black_polkilling=.40 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.45 black_polkilling=.45 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.5  black_polkilling=.50 hisp_resp=0 hisp_polkilling=0) rest(mean) 
prvalue, x(black_resp=1 zip_percap_polkillings=.55 black_polkilling=.55 hisp_resp=0 hisp_polkilling=0) rest(mean) 

prvalue, x(black_resp=0 zip_percap_polkillings=0   black_polkilling=0 hisp_resp=1 hisp_polkilling=0)   rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.05 black_polkilling=0 hisp_resp=1 hisp_polkilling=.05) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.1  black_polkilling=0 hisp_resp=1 hisp_polkilling=.1)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.15 black_polkilling=0 hisp_resp=1 hisp_polkilling=.15) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.2  black_polkilling=0 hisp_resp=1 hisp_polkilling=.2)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.25 black_polkilling=0 hisp_resp=1 hisp_polkilling=.25) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.3  black_polkilling=0 hisp_resp=1 hisp_polkilling=.3)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.35 black_polkilling=0 hisp_resp=1 hisp_polkilling=.35) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.4  black_polkilling=0 hisp_resp=1 hisp_polkilling=.4)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.45 black_polkilling=0 hisp_resp=1 hisp_polkilling=.45) rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.5  black_polkilling=0 hisp_resp=1 hisp_polkilling=.5)  rest(mean) 
prvalue, x(black_resp=0 zip_percap_polkillings=.55 black_polkilling=0 hisp_resp=1 hisp_polkilling=.55) rest(mean) 

close

/* Figure 1*/

use "Figure 1 data.dta"
twoway rcap min95 max95 variable2 if model=="Protest" & race=="police" || scatter estimate variable2 if model=="Protest" & race=="police", yline(0)  legend(off) scheme(plotplain) title("Protest Effectiveness") ylabel(, nogrid notick) xlabel(1 "Not At All" 2 "Not Too" 3 "Somewhat" 4 "Very", nogrid notick) lpatter(solid) lcolor(black) msymbol(circle) mcolor(black) xtitle("") xscale(r(1 4.05))
graph save protest, replace

twoway rcap min95 max95 variable2 if model=="Voting" & race=="police" || scatter estimate variable2 if model=="Voting" & race=="police", yline(0) legend(off) scheme(plotplain) title("Voting Effectiveness") ylabel(, nogrid notick) xlabel(1 "Not At All" 2 "Not Too" 3 "Somewhat" 4 "Very", nogrid notick) lpatter(solid) lcolor(black) msymbol(circle) mcolor(black) xtitle("") xscale(r(1 4.05))
graph save voting, replace
gr combine protest.gph voting.gph, scheme(plotplain) title("Figure 1. The Impact of Police Violence on the Perceived Effectiveness of Participation")


use "Figures 2-3 data.dta "

eclplot estimate min95 max95 range if variable2==1 & variable=="Not At All" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("Whites") ytitle("Probability") xtitle("Zip Code Police Violence") saving(protest1_white.gph, replace)
eclplot estimate min95 max95 range if variable2==2 & variable=="Not At All" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("African Americans") ytitle(" ") xtitle("Zip Code Police Violence") saving(protest1_black.gph, replace)
eclplot estimate min95 max95 range if variable2==3 & variable=="Not At All" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("Latinos") ytitle("Probability") xtitle("Zip Code Police Violence") saving(protest1_latino.gph, replace)
gr combine protest1_white.gph protest1_black.gph protest1_latino.gph,  scheme(plotplain) row(1) imargin(0 0 0)  ycommon title("Not At All Effective") saving(protest1.gph, replace)
 

eclplot estimate min95 max95 range if variable2==1 & variable=="Very Effective" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("Whites") ytitle("Probability") xtitle("Zip Code Police Violence") saving(protest4_white.gph, replace)
eclplot estimate min95 max95 range if variable2==2 & variable=="Very Effective" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("African Americans") ytitle(" ") xtitle("Zip Code Police Violence") title("African Americans") saving(protest4_black.gph, replace)
eclplot estimate min95 max95 range if variable2==3 & variable=="Very Effective" & model=="Protest", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black)) legend(off) yline(0) scheme(plotplain) xlabel(, nogrid) ylabel(, nogrid) title("Latinos") ytitle(" ") xtitle("Zip Code Police Violence") title("Latinos") saving(protest4_latino.gph, replace)
gr combine protest4_white.gph protest4_black.gph protest4_latino.gph,  scheme(plotplain) row(1) imargin(0 0 0)  ycommon title("Very Effective") saving(protest4.gph, replace)
gr combine protest1.gph protest4.gph, ycommon xcommon fxsize(350) fysize(350) scheme(plotplain) row(2) title("Figure 2. Racial Difference in Perceived Effectiveness of Protest") saving(protest_R&R.gph, replace)


eclplot estimate min95 max95 range if variable2==1 & variable=="Not At All" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("Whites") ytitle("Probability") xtitle("Zip Code Police Violence") saving(vote1_white.gph, replace)
eclplot estimate min95 max95 range if variable2==2 & variable=="Not At All" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("African Americans") ytitle(" ") xtitle("Zip Code Police Violence") saving(vote1_black.gph, replace)
eclplot estimate min95 max95 range if variable2==3 & variable=="Not At All" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("Latinos") ytitle(" ") xtitle("Zip Code Police Violence") saving(vote1_latino.gph, replace)
gr combine vote1_white.gph vote1_black.gph vote1_latino.gph,  scheme(plotplain) row(1) imargin(0 0 0)  ycommon title("Not At All Effective") saving(vote1.gph, replace)

eclplot estimate min95 max95 range if variable2==1 & variable=="Very Effective" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("Whites") ytitle("Probability") xtitle("Zip Code Police Violence") saving(vote4_white.gph, replace)
eclplot estimate min95 max95 range if variable2==2 & variable=="Very Effective" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("African Americans") ytitle(" ") xtitle("Zip Code Police Violence") saving(vote4_black.gph, replace)
eclplot estimate min95 max95 range if variable2==3 & variable=="Very Effective" & model=="Voting", estopts(msymbol(circle) msize(medsmall) mcolor(black)) ciopts(msize(medium) bcolor(black))  legend(off) yline(0) scheme(plotplain)  xlabel(, nogrid) ylabel(, nogrid) title("Latinos") ytitle(" ") xtitle("Zip Code Police Violence") saving(vote4_latino.gph, replace)
gr combine vote4_white.gph vote4_black.gph vote4_latino.gph,  scheme(plotplain) row(1) imargin(0 0 0)  ycommon  title("Very Effective") saving(vote4.gph, replace)
gr combine vote1.gph vote4.gph, ycommon xcommon fxsize(220) fysize(220) scheme(plotplain) row(2) title("Figure 3. Racial Difference in Perceived Effectiveness of Voting") saving(vote_R&R.gph, replace)

